package J5_7;

import java.util.*;

public class test {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int mid = n / 2 + 1;
        List<Integer> res = new ArrayList<>();
        if (n % 2 == 1) {
            res.add(mid++);
        }
        for (int i = mid, j = 1; i <= n; i++, j++) {
            res.add(i);
            res.add(j);
        }
        res.forEach(a -> {
            System.out.print(a + " ");
        });
    }
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < n + m; i++) {
            set.add(in.nextInt());
        }
        int count = 1;
        for (int a : set) {
            System.out.print(a);
            if (count != n + m) {
                System.out.print(" ");
                count++;
            }
        }

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int length = str.length();
        int[][] dp = new int[length][length];
        String[][] res = new String[length][length];
        for (int i = length - 1; i >= 0; i--) {
            for (int j = i; j < length; j++) {
                if (str.charAt(i) == str.charAt(j)) {
                    if (i == j) {
                        dp[i][j] = 1;
                        res[i][j] = str.charAt(i) + "";
                    } else if (i + 1 == j) {
                        dp[i][j] = 2;
                        char[] ch = {str.charAt(i), str.charAt(i + 1)};
                        res[i][j] = new String(ch);
                    } else {
                            dp[i][j] = dp[i + 1][j - 1] + 2;
                            StringBuilder s = new StringBuilder();
                            s.append(str.charAt(i));
                            s.append(res[i+1][j - 1]);
                            s.append(str.charAt(i));
                            res[i][j] = s.toString();
                    }
                } else {
                    if (dp[i + 1][j] > dp[i][j - 1]) {
                        dp[i][j] = dp[i + 1][j];
                        res[i][j] = res[i + 1][j];
                    } else {
                        dp[i][j] = dp[i][j - 1];
                        res[i][j] = res[i][j-1];
                    }
                }
            }
        }
        System.out.println(res[0][length-1]);
    }
}
